package cn.lili.controller.user;

import cn.lili.common.aop.annotation.PreventDuplicateSubmissions;
import cn.lili.common.security.AuthUser;
import cn.lili.common.utils.ResultUtil;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.member.entity.dos.CityDistribution;
import cn.lili.modules.member.entity.dos.User;
import cn.lili.modules.member.entity.dto.CityDistributionDTO;
import cn.lili.modules.member.service.CityDistributionService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* @author asus
* @description 针对表【li_city_distribution(城主表)】的数据库操作Service
* @createDate 2024-01-08 20:19:05
*/
@Api(tags = "城主管理接口")
@RestController
@RequestMapping("/user/city/distribution")
@RequiredArgsConstructor
@Validated
public class CityDistributionController {

    private final CityDistributionService cityDistributionService;

    /**
     * 是不是本月城主
     * @return true/false
     */
    @GetMapping("/isCastellan")
    public ResultMessage<Object> isCastellan() {
        return cityDistributionService.isCastellan();
    }

    /**
     * 获取城主区域分组
     */
    @GetMapping("/getCastellanRegionGroup")
    public ResultMessage<Object> getCastellanRegionGroup() {
        return cityDistributionService.getCastellanRegionGroup();
    }

    @GetMapping("/cityDistributionPage")
    @ApiOperation(value ="城主列表")
    public ResultMessage<Page<CityDistribution>> getCityDistributionPage(CityDistributionDTO dto){
        return ResultUtil.data(cityDistributionService.getCityDistribution(dto));
    }

    @PostMapping("/cancelcityDistribution")
    @ApiOperation(value ="取消城主资格")
    @PreventDuplicateSubmissions
    public ResultMessage<Object> cancelcityDistribution(@RequestBody @Validated CityDistributionDTO dto) {
        return cityDistributionService.cancelcityDistribution(dto);
    }

    @GetMapping("/cityDistributionById")
    @ApiOperation(value ="根据城主id查询城主信息")
    public ResultMessage<CityDistribution> cityDistributionById(@RequestParam String id) {
        return ResultUtil.data(cityDistributionService.getById(id));
    }

    @PostMapping("/setCityDistributionUser")
    @ApiOperation(value ="指定城主")
    @PreventDuplicateSubmissions
    public ResultMessage<Object> setCityDistributionUser(@RequestBody @Validated CityDistributionDTO dto){
        return ResultUtil.data(cityDistributionService.setCityDistributionUser(dto));
    }

    @PostMapping("/changeCityDistributionUser")
    @ApiOperation(value ="更换城主")
    @PreventDuplicateSubmissions
    public ResultMessage<Object> changeCityDistributionUser(@RequestBody @Validated CityDistributionDTO dto){
        return ResultUtil.data(cityDistributionService.changeCityDistributionUser(dto));
    }



    /**
     * 运营中心-城主统计-城主列表
     */
    @GetMapping("/operationCityDistributionList")
    @ApiOperation("运营中心-城主统计-城主列表")
    public ResultMessage<Page<CityDistribution>> operationCityDistributionList(CityDistributionDTO dto) {
        return ResultUtil.data(cityDistributionService.operationCityDistributionList(dto));
    }


}
